package com.bw.crop.controller;

import com.bw.crop.domain.SysLogsWarehouse;
import com.bw.crop.service.SysLogsWarehouseService;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/exchat")
public class EchartController {
    @Autowired
    private SysLogsWarehouseService logsWarehouseService;
    @RequestMapping("/list")
    public R list(String outInGoods){
        List<SysLogsWarehouse> getechartlist = logsWarehouseService.getechartlist(outInGoods);
        //採購
        List<Integer> inlist = getechartlist.stream()
                .map(SysLogsWarehouse::getInQuantity)
                .collect(Collectors.toList());
        //銷售
        List<Integer> outlist = getechartlist.stream()
                .map(SysLogsWarehouse::getOutQuantity)
                .collect(Collectors.toList());
        //庫存
        List<Integer> relist = getechartlist.stream()
                .map(SysLogsWarehouse::getRemainQuantity)
                .collect(Collectors.toList());
        //名稱
        List<String> namelist = getechartlist.stream()
                .map(SysLogsWarehouse::getOutInGoods)
                .collect(Collectors.toList());
        //名稱
        List<Integer> monthlist = getechartlist.stream()
                .map(SysLogsWarehouse::getMonth)
                .collect(Collectors.toList());
        Map<Object, Object> map = new HashMap<>();
        map.put("inlist",inlist);
        map.put("outlist",outlist);
        map.put("relist",relist);
        map.put("namelist",namelist);
        map.put("monthlist",monthlist);
        return R.ok(getechartlist);
    }
}
